﻿<%@ Page Language="C#" MasterPageFile="~/Manager/Main.master" AutoEventWireup="true" CodeFile="MaterialOrderAdd.aspx.cs" Inherits="MaterialOrderAdd" Title="订单管理" %>

<asp:Content ID="Content1" ContentPlaceHolderID="HeadMain" Runat="Server">
<script language="javascript" src="../js/calendar.js" type="text/javascript"></script>
<script language="javascript" type="text/javascript">

function toRight(){
  var selAllUser =  document.getElementById("<%= this.lstAll.ClientID %>") ;
  var selOpts = selAllUser.options;
  
  var selUser = document.getElementById("<%= this.lstSelected.ClientID %>");
 
  for(var i=selOpts.length;i>0;i--)
  { 
    if(selOpts[i-1].selected )
    {
        //alert(selOpts[i-1]);
        var newOpt = document.createElement("OPTION");
        newOpt.value = selOpts[i-1].value;
        newOpt.text = selOpts[i-1].text;
         
        selUser.add(newOpt);
        selAllUser.remove(i-1);
    }
  }
  
}   
function toLeft(){
  var selAllUser =  document.getElementById("<%= this.lstAll.ClientID %>") ;
  var selUser = document.getElementById("<%= this.lstSelected.ClientID %>");
  var selOpts = selUser.options;
 
  for(var i=selOpts.length;i>0;i--)
  { 
    if(selOpts[i-1].selected )
    {
        //alert(selOpts[i-1]);
        var newOpt = document.createElement("OPTION");
        newOpt.value = selOpts[i-1].value;
        newOpt.text = selOpts[i-1].text;
         
        selAllUser.add(newOpt);
        selUser.remove(i-1);
    }
  }
}
 function ShowRightList()
{
   
    var strIds = document.getElementById("<%= this.userIds.ClientID %>").value;
 
    if(strIds.length>0)
    {
        var arr = strIds.split(",");
        var selAllUser =  document.getElementById("<%= this.lstAll.ClientID %>") ;
        
        var selUser = document.getElementById("<%= this.lstSelected.ClientID %>");
 
        for(var i=0;i<arr.length;i++)
        {
           id = arr[i];
            var selOpts = selAllUser.options; 
            for(var j=0;j<selOpts.length;j++)
            {  
                if(selOpts[j].value == id )
                { 
                    var newOpt = document.createElement("OPTION");
                    newOpt.value = selOpts[j].value;
                    newOpt.text = selOpts[j].text;
                     
                    selUser.add(newOpt);
                    selAllUser.remove(j);
                    break;
                }
            }
        }
        
    }
        var rightTypes = document.getElementsByName("<%= this.rdBtnRight.UniqueID %>");
    var iVal; 
    for(var i=0;i<rightTypes.length;i++)
    {
        if(rightTypes[i].checked)
        {
            iVal = rightTypes[i].value;
            break;
        }
    }
    var div = document.getElementById("divSelectedUser"); 
    if(iVal==0)
    {      
        div.style.display="none";
    }
    else
    {
        div.style.display="block";
    }
}
function BeforCommint()
{
    var txtIds = document.getElementById("<%= this.userIds.ClientID %>");
    var selUser = document.getElementById("<%= this.lstSelected.ClientID %>");
    var selOpts = selUser.options;
    var vals = "";
    
    for(var i=0;i<selOpts.length;i++)
    { 
        vals += selOpts[i].value+",";
    }
    
    if(vals.length>0)
        vals = vals.substring(0,vals.length-1);
    txtIds.value = vals;
    return true;
}
$(document).ready(function(){ 
 
 ShowRightList();
    
})
</script>
<style type="text/css">
.userList{ 
    width:260px;  
    height:220px;
    overflow:scroll; 
}

</style>


</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<script language="javascript" type="text/javascript">

</script>
  <div style="width: 100%; color: #014d7f; padding-top: 5px; height: 25px; background-color: #f3f8fe">
    &nbsp; &nbsp;<asp:Label ID="labHeader" runat="server" Text="Label"></asp:Label>原料订单</div>    
    <div style="margin-left:50px;">  
        <table>
 
            <tr>
                <td>名称：</td>
                <td>
                    <asp:TextBox ID="txtName" runat="server" Width="200px"></asp:TextBox></td>
            </tr>
            <tr>
                <td>规格：</td>
                <td>
                    <asp:TextBox ID="txtSpec" runat="server" Width="200px"></asp:TextBox></td>
            </tr>
            <tr>
                <td>数量：</td>
                <td>
                    <asp:TextBox ID="txtAmont" runat="server"></asp:TextBox></td>
            </tr>
            <tr>
                <td>竞价结束时间：</td>
                <td>
                    <asp:TextBox ID="txtEndDate" runat="server" onfocus="calendar()"></asp:TextBox></td>
            </tr>
            <tr>
                <td>交期：</td>
                <td>
                    <asp:TextBox ID="txtDeliveryDate" runat="server" onfocus="calendar()"></asp:TextBox></td>
            </tr>
            <tr>
                <td>备注：</td>
                <td>
                    <asp:TextBox ID="txtComment" runat="server" Width="300px"></asp:TextBox></td>
            </tr>
            <tr>
                <td colspan="2">查看权限：
                    <asp:RadioButtonList ID="rdBtnRight" runat="server"  >
                        <asp:ListItem Text="所有供应商" Value="0"  onclick="ShowRightList()"></asp:ListItem>
                        <asp:ListItem Text="指定供应商" Value="1" onclick="ShowRightList()"></asp:ListItem>
                        
                    </asp:RadioButtonList>
                    <div id="divSelectedUser" style="display:block;">
                            <span style="float:left; width:260px;">
                                <asp:ListBox ID="lstAll" DataTextField="uName" DataValueField="uId" runat="server" CssClass="userList" SelectionMode="Multiple"></asp:ListBox>
                            </span>
                            <span style="float:left; width:40px;">
                                <input type="button" onclick="toRight()" value=">>" title="加入" /> 
                                <input type="button" onclick="toLeft()" value="<<" title="减少" />
                            </span>
                            <span style="float:left; width:260px;">
                                <asp:ListBox ID="lstSelected" DataTextField="uName" DataValueField="uId" runat="server" CssClass="userList" SelectionMode="Multiple"></asp:ListBox>
                            </span>
                    </div>
                </td>
                
            </tr>
            <tr>
                <td colspan="2">
                    <asp:Button ID="btnSave" runat="server" Text="添加" OnClick="btnSave_Click" OnClientClick="return BeforCommint()" />
                    <asp:Button ID="btnRelease" runat="server" Text="发布竞价" Enabled="false"  />
                    <input type="button" onclick="window.location.href='MaterialOrderMy.aspx'" value="返回列表" />
                    
                </td>
            </tr>
        </table>
    </div>
    <div style="display:none">
        <asp:TextBox ID="userIds" runat="server"></asp:TextBox>
        <asp:HiddenField ID="txtId" runat="server" Value="0" />
    </div>
</asp:Content>

